{
    "args" : {
        "password" : "0000",
        "db_pass" : "<RND_STR>",
        "include" : "webserver",
        "packages" : "openssh sudo openvpn easy-rsa powerdns",
        "post" : "stay",
        "country" : "SE",
        "mirrors" : true
    },
    "post" : {
        "install database": "postgresql",
        "Configure database": {
            "su - postgres -c 'psql -c \"CREATE DATABASE pdns;\"'" : {"boot" : true, "debug" : true},
            "su - postgres -c 'psql -c \"CREATE USER pdns WITH ENCRYPTED PASSWORD \\'{db_pass}\\';\"'" : {"boot" : true, "debug" : true},
            "su - postgres -c 'psql -c \"GRANT ALL PRIVILEGES ON DATABASE pdns TO pdns;\"'" : {"boot" : true, "debug" : true},
            "psql -U pdns -d pdns -a -f /usr/share/doc/powerdns/schema.pgsql.sql" : {"boot" : true, "debug" : true},
            "echo '{db_pass}' > /mnt/root/db_pass.txt" : {"no-chroot" : true, "pass-args" : true},
            "echo 'launch=gpgsql' >> /mnt/etc/powerdns/pdns.conf" : {"no-chroot" : true},
            "echo 'gpgsql-host=127.0.0.1' >> /mnt/etc/powerdns/pdns.conf" : {"no-chroot" : true},
            "echo 'gpgsql-port=5432' >> /mnt/etc/powerdns/pdns.conf" : {"no-chroot" : true},
            "echo 'gpgsql-dbname=pdns' >> /mnt/etc/powerdns/pdns.conf" : {"no-chroot" : true},
            "echo 'gpgsql-user=pdns' >> /mnt/etc/powerdns/pdns.conf" : {"no-chroot" : true},
            "echo 'gpgsql-password=\"{db_pass}\"' >> /mnt/etc/powerdns/pdns.conf" : {"no-chroot" : true, "pass-args" : true}
        },
        "Configure OpenVPN" : {
            "mkdir -p /etc/openvpn/server/vpn_ccd" : null,
            "echo 'port 112' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'proto udp' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'dev tap' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'ca ca.crt' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'cert vpn.hvornum.se.crt' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'key vpn.hvornum.se.key' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'tls-crypt ta.key' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'dh dh.pem' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'server 10.0.50.0 255.255.255.0' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'ifconfig-pool-persist ipp.txt' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'client-config-dir /vpn_ccd' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'client-to-client' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'keepalive 10 120' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'cipher AES-256-CBC' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'tls-version-min 1.2' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'tls-cipher TLS-DHE-RSA-WITH-AES-256-GCM-SHA384:TLS-DHE-RSA-WITH-AES-128-GCM-SHA256:TLS-DHE-RSA-WITH-AES-256-CBC-SHA:TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA:TLS-DHE-RSA-WITH-AES-128-CBC-SHA:TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'auth SHA512' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'compress lz4-v2' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'push \"compress lz4-v2\"' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'user nobody' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'group nobody' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'persist-key' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'persist-tun' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'verb 4' >> /mnt/etc/openvpn/server/vpn.hvornum.se.conf": {"no-chroot" : true},
            "echo 'push \"dhcp-option DNS 8.8.8.8\"' >> /mnt/etc/openvpn/server/vpn_ccd/nas.hvornum.se": {"no-chroot" : true},
            "echo 'push \"redirect-gateway autolocal bypass-dhcp\"' >> /mnt/etc/openvpn/server/vpn_ccd/nas.hvornum.se": {"no-chroot" : true},
            "echo 'push \"dhcp-option DNS 8.8.8.8\"' >> /mnt/etc/openvpn/server/vpn_ccd/laptop": {"no-chroot" : true},
            "echo 'push \"redirect-gateway def1 bypass-dhcp\"' >> /mnt/etc/openvpn/server/vpn_ccd/laptop": {"no-chroot" : true}
        },
        "Create vhost table" : {
            "echo 'defaultzone = { docroot \"/srv/http/default\"; index [\"index.html\"]; };' >> /mnt/etc/lighttpd2/vhost.conf": {"no-chroot" : true},
            "echo 'hvornum = { docroot \"/srv/http/default\"; index [\"index.html\"]; };' >> /mnt/etc/lighttpd2/vhost.conf": {"no-chroot" : true},
            "echo 'vhost.map [default => defaultzone, \"hvornum.se\" => hvornum];' >> /mnt/etc/lighttpd2/vhost.conf": {"no-chroot" : true}
        },
        "Configure helpers" : {
          "echo '[Unit]' >> /mnt/etc/systemd/system/issue.service": {"no-chroot" : true},
          "echo 'Description=MOTD Updater' >> /mnt/etc/systemd/system/issue.service": {"no-chroot" : true},
          "echo '[Service]' >> /mnt/etc/systemd/system/issue.service": {"no-chroot" : true},
          "echo 'ExecStart=/usr/bin/motd_updater' >> /mnt/etc/systemd/system/issue.service": {"no-chroot" : true},
          "echo '[Install]' >> /mnt/etc/systemd/system/issue.service": {"no-chroot" : true},
          "echo 'WantedBy=multi-user.target' >> /mnt/etc/systemd/system/issue.service": {"no-chroot" : true},
          "echo '#!/bin/bash' > /mnt/usr/bin/motd_updater": {"no-chroot" : true},
          "echo 'cat /etc/hostname > /etc/issue' >> /mnt/usr/bin/motd_updater": {"no-chroot" : true},
          "hostname -i >> /etc/issue' >> /mnt/usr/bin/motd_updater": {"no-chroot" : true},
          "chmod +x /mnt/usr/bin/motd_updater": {"no-chroot" : true},
          "systemctl enable issue.service": {"boot" : true}
        }
    }
}
